#include <iostream>
#include <vector>
#include <iomanip>
#include <cassert>
using namespace std;
class Graph;
class myIterator {
public:
	myIterator(Graph& g, int v);
	int begin();
	int next();
	bool end();
	int now();
private:
	Graph& G;
	int v;
	int index;
};

class Graph {
public:
	friend class myIterator;
	Graph(int n);
	~Graph();
	bool hasEdge(int v1, int v2);
	void addEdge(int v1, int v2);
	void eraseEdge(int v1, int v2);
	int getNumofNode() { return num_node; }
	int getNumofEdge() { return num_edge; }
	int* findPath(int theSource, int theDestination);
	bool rFindPath(int s);
	int* findPath2(int theSource, int theDestination);
	int labelComponents(int* c);
	void bfs(int i, int* c, int label);
	bool** undirectedTC();
private:
	int num_node;
	int num_edge;
	vector<vector<bool>> graph;

	static int* path;
	static int* reach;
	static int length;
	static int destination;
};
class Queue {
public:
	Queue(int size);
	~Queue();
	bool pop(int& x);
	bool push(int x);
	int first();
	int last();
	bool isEmpty();
private:
	int* queue;
	int front;
	int rear;
	int size;
};
